package com.jvtd.nettyim.im.client.console;

import com.jvtd.nettyim.im.protocol.request.CreateGroupRequestPacket;
import io.netty.channel.Channel;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author Created by neal.zhang
 * @date 2020/6/1 - 12:01
 */
public class CreateGroupConsoleCommand implements ConsoleCommand{

    private static final String USER_ID_SPLITER=",";

    @Override
    public void exec(Scanner scanner, Channel channel) {
        CreateGroupRequestPacket createGroupRequestPacket = new CreateGroupRequestPacket();
        System.err.print("【拉人群聊】输入 userId 列表，userId 之间英文逗号隔开：\"");
        String userId = scanner.next();
        createGroupRequestPacket.setUserIdList(Arrays.asList(userId.split(USER_ID_SPLITER)));
        channel.writeAndFlush(createGroupRequestPacket);
    }
}
